<!-- $Id: goods_search.htm 16790 2009-11-10 08:56:15Z wangleisvn $ -->
<link href="styles/zTree/zTreeStyle.css" rel="stylesheet" type="text/css" />
<link href="styles/chosen/chosen.css" rel="stylesheet" type="text/css">
{insert_scripts files='jquery-1.6.2.min.js,chosen.jquery.min.js,jquery.ztree.all-3.5.min.js,category_selecter.js'}
<div class="form-div">
    <form action="javascript:searchGoods()" name="searchForm">
        <img src="images/icon_search.gif" width="26" height="22" border="0" alt="SEARCH" />
        {if $smarty.get.act neq "trash"}
        <!-- 分类 -->
        <input type="text" id="cat_name" name="cat_name" nowvalue="{$goods_cat_name}" value="{$goods_cat_name}" >
        <input type="hidden" id="cat_id" name="cat_id" value="{$goods_cat_id}">
        <!-- 品牌 -->
        <select  class="chzn-select" name="brand_id"><option value="0">{$lang.goods_brand}</option>{html_options options=$brand_list}</select>
        <!-- 推荐 -->
        {if $suppliers_exists == 0}
        {if $intro_list neq ''}
        <select class="chzn-select" name="intro_type"><option value="0">{$lang.intro_type}</option>
            {html_options options=$intro_list selected=$smarty.get.intro_type}
        </select>
        {/if}
        {/if}
        {if $suppliers_exists eq 1}
        <!-- 供货商 -->
        <select class="chzn-select" name="suppliers_id" style="height:100;"><option value="0">{$lang.intro_type}</option>{html_options options=$suppliers_list_name selected=$smarty.get.suppliers_id}</select>

        {* 代码增加_start  By  www.68ecshop.com *}
        <select class="chzn-select" name="supplier_status"><option value="">审核状态</option>
            {foreach from=$supplier_status_list key=supplier_key item=supplier_status}
            <option value="{$supplier_key}" {if $supplier_key neq ''  and $supplier_key eq $smarty.get.supplier_status}selected{/if}>{$supplier_status}</option>
            {/foreach}
        </select>
        {* 代码增加_end  By  www.68ecshop.com *}
        {/if}
        <!-- 上架 -->
        {if $lang.intro_type neq ''}
        <select class="chzn-select" name="is_on_sale"><option value=''>{$lang.intro_type}</option><option value="1">{$lang.on_sale}</option><option value="0">{$lang.not_on_sale}</option></select>
        {/if}
        {/if}
        <!-- 关键字 -->
        关键字 <input type="text" name="keyword" size="15" />
        <input type="submit" value="{$lang.button_search}" class="button" />
         {if $is_pre_sale neq '1'}
        <input type="button" value="批量导出" class="button" onclick="batch_export()" />
         {/if}
        
    </form>
</div>

{literal}
<script language="JavaScript">

    $().ready(function(){
       $(".chzn-select").chosen();
       $(".chzn-container").click(function(){
     	$("#menuContent_cat_id").hide();
    	})
		$('.chzn-container-single:last').css('width','60px');
    });

    function searchGoods()
    {
        {/literal}
        {if $smarty.get.act neq "trash"}
        listTable.filter['cat_id'] = document.forms['searchForm'].elements['cat_id'].value;
        listTable.filter['brand_id'] = document.forms['searchForm'].elements['brand_id'].value;
        {if $suppliers_exists == 0}
            listTable.filter['intro_type'] = document.forms['searchForm'].elements['intro_type'].value;
            {/if}
                {if $suppliers_exists eq 1}
                listTable.filter['suppliers_id'] = document.forms['searchForm'].elements['suppliers_id'].value;
                /* 代码增加_start  By  www.68ecshop.com */
                listTable.filter['supplier_status'] = document.forms['searchForm'].elements['supplier_status'].value;
                /* 代码增加_end  By  www.68ecshop.com */
                {/if}
                    listTable.filter['is_on_sale'] = document.forms['searchForm'].elements['is_on_sale'].value;
                    {/if}
                        {literal}
                        listTable.filter['keyword'] = Utils.trim(document.forms['searchForm'].elements['keyword'].value);

                        listTable.filter['page'] = 1;

                        listTable.loadList();
                    }
</script>
{/literal}
<script type="text/javascript">
    $().ready(function(){
        // $("#cat_name")为获取分类名称的jQuery对象，可根据实际情况修改
        // $("#cat_id")为获取分类ID的jQuery对象，可根据实际情况修改
        // "{$goods_cat_id}"为被选中的商品分类编号，无则设置为null或者不写此参数或者为空字符串
        $.ajaxCategorySelecter($("#cat_name"), $("#cat_id"), "{$goods_cat_id}");
    });

    function searchSuppliers()
    {
        var filter = new Object;
        filter.keyword = document.forms['searchForm'].elements['search_suppliers'].value;
        Ajax.call('goods.php?is_ajax=1&act=search_suppliers', filter, searchSuppliersResponse, 'GET', 'JSON')
    }

    function searchSuppliersResponse(result)
    {
    	
        var frm = document.forms['searchForm'];
        var sel = frm.elements['suppliers_id'];

        if (result.error == 0)
        {
            /* 清除 options */
            sel.length = 0;

            /* 创建 options */
            var suppliers = result.content;
            if (suppliers)
            {
                for (i = 0; i < suppliers.length; i++)
                {
                    var opt = document.createElement("OPTION");
                    opt.value = suppliers[i].supplier_id;
                    opt.text  = suppliers[i].supplier_name;
                    sel.options.add(opt);
                }
            }
            else
            {
                var opt = document.createElement("OPTION");
                opt.value = 0;
                opt.text  = search_is_null;
                sel.options.add(opt);
            }
        }

        if (result.message.length > 0)
        {
            alert(result.message);
        }
    }

    function batch_export()
    {
        // 分类
        var cat_id = document.forms['searchForm'].elements['cat_id'].value;
        // 品牌
        var brand_id = document.forms['searchForm'].elements['brand_id'].value;
        // 入驻商
        if (typeof(document.forms['searchForm'].elements['suppliers_id']) == "undefined")
        {
            var suppliers_exists = 0;
            var suppliers_id = 0;
        }
        else
        {
            var suppliers_exists = 1;
            var suppliers_id = document.forms['searchForm'].elements['suppliers_id'].value;
        }
        // 审核状态
        if (typeof(document.forms['searchForm'].elements['supplier_status']) == "undefined")
        {
            var supplier_status = '';
        }
        else
        {
            var supplier_status = document.forms['searchForm'].elements['supplier_status'].value;
        }
        // 推荐
        if (typeof(document.forms['searchForm'].elements['intro_type']) == "undefined")
        {
            var intro_type = '';
        }
        else
        {
            var intro_type = document.forms['searchForm'].elements['intro_type'].value;
        }
        // 上架
        var is_on_sale = document.forms['searchForm'].elements['is_on_sale'].value;
        // 搜索关键字
        var keyword = Utils.trim(document.forms['searchForm'].elements['keyword'].value);
        return location.href='goods.php?act=export&cat_id='+cat_id+'&brand_id='
                +brand_id+'&suppliers_id='+suppliers_id+'&supplier_status='+supplier_status+
                '&intro_type='+intro_type+'&is_on_sale='+is_on_sale+'&keyword='+keyword+'&suppliers_exists='+suppliers_exists;
    }
</script>